home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Santa + Projectile Santa + Projectile Gift
- -- Original Carnage Contest Weapon
- -- Script by DC, September 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.santa={}
- cc.santa.santa={}
- cc.santa.gift={}
-
- -- Load & Prepare Ressources
- cc.santa.gfx_wpn=loadgfx("weapons/santa.bmp") -- Weapon Image
- setmidhandle(cc.santa.gfx_wpn)
- cc.santa.gfx_sleigh0=loadgfx("weapons/santa0.bmp") -- Sleigh Frame 1
- setmidhandle(cc.santa.gfx_sleigh0)
- cc.santa.gfx_sleigh1=loadgfx("weapons/santa1.bmp") -- Sleigh Frame 2
- setmidhandle(cc.santa.gfx_sleigh1)
- cc.santa.gfx_gift=loadgfx("weapons/gift.bmp") -- Gift
- setmidhandle(cc.santa.gfx_gift)
- cc.santa.sfx_hohoho=loadsfx("hohoho.ogg") -- HoHoHo Sound
- cc.santa.sfx_throw=loadsfx("throw.ogg") -- Throw Sound
- cc.santa.sfx_bounce=loadsfx("bounce.wav") -- Bounce Sound
-
- --------------------------------------------------------------------------------
- -- Weapon: Santa
- --------------------------------------------------------------------------------
-
- cc.santa.id=addweapon("cc.santa","Santa",cc.santa.gfx_wpn,0,2) -- Add Weapon (0 uses, first in round 2)
-
- function cc.santa.draw() -- Draw
- -- Do nothing
- end
-
- function cc.santa.attack(attack) -- Attack
- if (weapon_shots<=0) then
- if attack==1 then
- -- No more weapon switching!
- useweapon(0)
- playsound(cc.santa.sfx_hohoho)
- weapon_shots=weapon_shots+1
- id=createprojectile(cc.santa.santa.id)
- projectiles[id]={}
- -- Set initial position of projectile
- projectiles[id].x=-100
- projectiles[id].y=-150
- -- End Turn
- endturn()
- end
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Santa
- --------------------------------------------------------------------------------
-
- cc.santa.santa.id=addprojectile("cc.santa.santa") -- Add Projectile
-
- function cc.santa.santa.draw(id) -- Draw
- -- Setup draw mode
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- setscale(1,1)
- setrotation(0)
- -- Draw projectile
- weapon_timer=weapon_timer+1
- if weapon_timer>=10 then
- weapon_timer=0
- weapon_mode=1-weapon_mode
- end
- if weapon_mode==0 then
- drawimage(cc.santa.gfx_sleigh0,projectiles[id].x,projectiles[id].y)
- else
- drawimage(cc.santa.gfx_sleigh1,projectiles[id].x,projectiles[id].y)
- end
- end
-
- function cc.santa.santa.update(id) -- Update
- -- Particle Tail
- particle(p_lightpuff,projectiles[id].x+50,projectiles[id].y+20)
- particlespeed(math.random(-2,2)*0.1,math.random(-3,3)*0.1)
- particlecolor(100,0,math.random(0,255))
- particlefadealpha(0.01)
- -- Move
- projectiles[id].x=projectiles[id].x+5
- -- In Drop Area?
- if projectiles[id].x<=(getmapwidth()+100) then
- -- Drop Stuff
- if math.mod(projectiles[id].x,200)==0 then
- -- Drop Gift
- playsound(cc.santa.sfx_throw)
- pid=createprojectile(cc.santa.gift.id)
- projectiles[pid]={}
- projectiles[pid].x=projectiles[id].x-30
- projectiles[pid].y=projectiles[id].y
- projectiles[pid].sx=0
- projectiles[pid].sy=2
- projectiles[pid].timer=5*50
- elseif math.mod(projectiles[id].x,100)==0 then
- -- Drop Supply
- playsound(cc.santa.sfx_throw)
- createobject(o_supply,projectiles[id].x-30,projectiles[id].y)
- end
- -- Scroll to projectile
- scroll(projectiles[id].x,projectiles[id].y)
- -- Free projectile
- elseif projectiles[id].x>(getmapwidth()+500) then
- -- Free projectile
- freeprojectile(id)
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Gift
- --------------------------------------------------------------------------------
-
- cc.santa.gift.id=addprojectile("cc.santa.gift") -- Add Projectile
-
- function cc.santa.gift.draw(id) -- Draw
- -- Setup draw mode
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- setscale(1,1)
- setrotation(0)
- -- Draw projectile
- drawimage(cc.santa.gfx_gift,projectiles[id].x,projectiles[id].y)
- -- Draw Arrow if out of Screen
- outofscreenarrow(projectiles[id].x,projectiles[id].y)
- end
-
- function cc.santa.gift.update(id) -- Update
- -- Gravity influence on speed
- projectiles[id].sy=projectiles[id].sy+getgravity()
- -- Move (in substep loop for optimal collision precision)
- msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/5)
- msubx=projectiles[id].sx/msubt
- msuby=projectiles[id].sy/msubt
- for i=1,msubt,1 do
- -- Move X
- projectiles[id].x=projectiles[id].x+msubx
- if collision(cc.santa.gfx_gift,projectiles[id].x,projectiles[id].y)==1 then
- if terraincollision()==1 or objectcollision()>0 or playercollision()~=projectiles[id].ignore then
- if (math.abs(projectiles[id].sx)>0.5) then playsound(cc.santa.sfx_bounce) end
- projectiles[id].x=projectiles[id].x-msubx
- projectiles[id].sx=-projectiles[id].sx*0.05
- msubx=-msubx*0.05
- end
- else
- projectiles[id].ignore=0
- end
- -- Move Y
- projectiles[id].y=projectiles[id].y+msuby
- if collision(cc.santa.gfx_gift,projectiles[id].x,projectiles[id].y)==1 then
- if terraincollision()==1 or objectcollision()>0 or playercollision()~=projectiles[id].ignore then
- if (math.abs(projectiles[id].sy)>0.5) then playsound(cc.santa.sfx_bounce) end
- projectiles[id].y=projectiles[id].y-msuby
- projectiles[id].sy=-projectiles[id].sy*0.3
- msuby=-msuby*0.3
- end
- else
- projectiles[id].ignore=0
- end
- -- Water
- if (projectiles[id].y)>getwatery()+5 then
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- playsound(sfx_hitwater1)
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- -- Timer -> Explode
- projectiles[id].timer=projectiles[id].timer-1
- if projectiles[id].timer<=0 then
- -- Scroll to projectile
- scroll(projectiles[id].x,projectiles[id].y)
- -- Cause damage
- arealdamage(projectiles[id].x,projectiles[id].y,125,65)
- -- Destroy terrain
- terrainexplosion(projectiles[id].x,projectiles[id].y,55,1)
- -- Crater
- grey=math.random(0,40)
- if math.random(0,1)==1 then
- terrainalphaimage(gfx_crater150,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- else
- terrainalphaimage(gfx_crater175,projectiles[id].x,projectiles[id].y,math.random(6,9)*0.1,grey,grey,grey)
- end
- stopchannel(0)
- -- Free projectile
- freeprojectile(id)
- end
- end
-